package com.sky.mapper;

import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.OrderDetail;
import com.sky.entity.Orders;
import com.sky.vo.ExcelDetailsVO;
import com.sky.vo.ExcelVO;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderAdminMapper {

    List<Integer> selectStatistics();

    List<Orders> selectConditionSearch(OrdersPageQueryDTO ordersPageQueryDTO);

    OrderVO getOrdersById(Long id);

    List<OrderDetail> getOrderDetailById(Long id);

    void updateDelivery(Orders orders);

    @Update("update orders set status = #{statusResult} where status = #{statusQuery} and pay_status = #{payStatus} and order_time <= #{orderTime}")
    Integer updateStatusByPayStatusAndOrderTime(Integer statusResult, Integer statusQuery, Integer payStatus, LocalDateTime orderTime);

    @Update("update orders set status = #{statusResult} where status = #{statusQuery}")
    Integer updateStatusByStatus(Integer statusResult, Integer statusQuery);

    List<Map<String, Object>> selectStatisticsBetweenOrderTime(LocalDate begin, LocalDate end);

    List<Map<String, Object>> selectStatisticsBetweenCreateTime(LocalDate begin, LocalDate end);

    List<Map<String, Object>> selectStatisticsBetweenOrdersTime(LocalDate begin, LocalDate end);

    List<Map<String, Object>> selectTop10(LocalDate begin, LocalDate end);

    ExcelVO selectExcelData(LocalDate begin, LocalDate end);

    List<ExcelDetailsVO> selectExcelDetailsVO(LocalDate begin, LocalDate end);
}
